<%@page contentType="text/html" pageEncoding="UTF-8" import="Funcionalidad.*,java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
   <jsp:include page="../Apariencia/Cabecera.jsp"/>
<%

                    if (session.getAttribute("loginuser")!=null){
                     int rol = (Integer)session.getAttribute("loginrol");
                    if(rol==1){
                        %>

<html>
<%
        List<Galeria> galerias = new ArrayList();
        try {
            galerias = Galerias.consultaGalerias();
        } catch (Exception ex) {
            out.print(ex.getMessage());
        }

%>
    <head>
        <title>FLOG - Administraci&oacute;n Galer&iacute;as</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <div id="administracion" class="admon">
        <body>
            <h1>ADMINISTRACI&Oacute;N Galer&iacute;as</h1>
<table border='0'>
            <%int cont = 0;%>
            <tr>
                <%Iterator it = galerias.iterator();
        while (it.hasNext()) {
            Galeria galeria = (Galeria) it.next();

            if (cont < 4) {%>

                <td>
                    <h2><%= galeria.getNombre()%>&nbsp;&nbsp;</h2><br/>
                    <a href="../Administracion/AdmonGaleria.jsp?id=<%= galeria.getId()%>"><IMG  src="<%= Galerias.consultaPrimeraFoto(galeria.getId())%>" width="200"/></a><br/>
                    <a href="../Administracion/BorraGaleria.jsp?id=<%= galeria.getId() %>">
                        <img src="../images/eliminar.png" class="x"> Suprimir</a>
                </td>

                <%cont++;
                    } else {
                        cont = 1;%>
            </tr>
            <tr>
                <td>
                    <h2><%= galeria.getNombre()%>&nbsp;&nbsp;</h2><br/>
                    <a href="../Administracion/AdmonGaleria.jsp?id=<%= galeria.getId()%>"><IMG  src="<%= Galerias.consultaPrimeraFoto(galeria.getId())%>" width="200"/></a><br/>
                    <a href="../Administracion/BorraGaleria.jsp?id=<%= galeria.getId() %>">
                        <img src="../images/eliminar.png" class="x"> Suprimir</a>
                </td>
                <%}%>
                <td>&nbsp&nbsp&nbsp&nbsp</td>

            <%}%>
        </table>
            

        </body>
    </div>
</html>
<%
                        }
                    else{
                    response.sendRedirect("../Apariencia/VistaPost.jsp");
                    }}
                  %>
